#ifndef __SUBSYSTEM_FENCE_GATE_BLOCK_BEHAVIOR_H__
#define __SUBSYSTEM_FENCE_GATE_BLOCK_BEHAVIOR_H__

#include <set>
#include <mutex>
#include "Engine/Point3.hpp"
#include "Subsystems/BlockBehaviors/SubsystemBlockBehavior.hpp"

using namespace PocketSurvival::Engine;

namespace PocketSurvival
{
    class SubsystemTerrain;

    class SubsystemFenceGateBlockBehavior : public SubsystemBlockBehavior
    {
    protected:
        SubsystemTerrain *m_terrain;

    protected:
        bool isGateElectricallyConnected(const Point3& point);

    public:
        inline bool openCloseGate(const Point3& point, bool open);
        bool openCloseGate(int32_t x, int32_t y, int32_t z, bool open);

        virtual bool onInteract(const TerrainRaycastResult &raycastResult, ComponentMiner *componentMiner) override;

        virtual void load(const nlohmann::json& json) override;
        virtual const std::string& getName() const override;
    };
    
    inline bool SubsystemFenceGateBlockBehavior::openCloseGate(const Point3& point, bool open)
    {
        return openCloseGate(point.posX, point.posY, point.posZ, open);
    }
}

#endif
